﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FetchToken.aspx.cs" Inherits="UI_FetchToken" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../js/jquery.easyui/jquery.min.js" type="text/javascript"></script>
    <script src="../js/common.js" type="text/javascript"></script>
    <link href="../css/admin.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(function() {
            $("#btnLoginPage").click(function() {
                $("#divInfo1").css('color', 'White');
                $("#divInfo2").css('color', 'White');
                $.get('../ebayServices.ashx', { "act": "getsessionid", "tname": "getsessionid", "ts": new Date().getTime() }, function(data, status) {
                    if (status == "success") {
                        var retData = EvalData(data);
                        if (retData.retCode == 0) {
                            var sessionId = retData.sessionId;
                            $("#txtSessionId").val(sessionId);
                            window.open(retData.loginUrl);
                            $("#divInfo1").css('color', 'Yellow');
                        }
                        else {
                            alert(retData.retMsg);
                        }
                    }
                    else {
                        alert('操作失败');
                    }
                });
            });

            $("#btnFetchToken").click(function() {
                var sessionId = $("#txtSessionId").val();
                if (sessionId == "") {
                    alert('请先点击打开登陆网页登陆后在获取Token');
                }
                $.get('../ebayServices.ashx', { "act": "fetchtoken", "tname": "getsessionid", "sessionid": sessionId, "ts": new Date().getTime() }, function(data, status) {
                    if (status == "success") {
                        var retData = EvalData(data);
                        if (retData.retCode == 0) {
                            var token = retData.token;
                            $("#txtToken").val(token);
                            $("#divInfo2").css('color', 'Yellow');
                        }
                        else {
                            alert(retData.retMsg);
                        }
                    }
                    else {
                        alert('操作失败');
                    }
                });
            });
        });
    </script>
    <style type="text/css">
        #txtToken
        {
            height: 188px;
            width: 749px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">    
    <input type="hidden" id="txtSessionId" />
        <div style="text-align:left;height:90px;line-height:90px; padding:10px;" class = "div_Title">
            <div id="div1" class="Body_Title">》》Ebay账户Token获取</div>
            <div id="divInfo1" class="Body_Title">1、点击《打开登陆网页》按钮登陆ebay网站</div>
            <div id="divInfo1" class="Body_Title">2、登陆后再点击《获取Token》按钮取得登陆后的Token</div>
        </div>
        <div style="padding:10px">
            <textarea id="txtToken"></textarea>
        </div>
        <div style="text-align:left;height:30px;line-height:30px; padding:10px;">
            <input id="btnLoginPage" type="button" value="打开登陆网页" />
            <input id="btnFetchToken" type="button" value="获取Token" />
        </div>
    </form>
</body>
</html>
